package demo1;

public class Test {
    public static void fun(Shape shape){
        shape.draw();
    }

    public static void main(String[] args) {
        Circle circle = new Circle();
        circle.draw();
        Rect rect = new Rect();
        rect.draw();

        System.out.println("==============");
        //上转型对象
        Shape shape = new Circle();
        shape.draw();
        fun(shape);
        System.out.println("===============");

        /// 下转型对象
        Shape shape1 = new Rect();
        if(shape1 instanceof Rect){
            Rect rect1 = (Rect) shape1;
            rect1.draw();
        }else {
            System.out.println("shape1没有引用Rect");
        }

        if(shape1 instanceof Circle) {
            Circle circle1 = (Circle) shape1;
            circle1.draw();
        }else {
            System.out.println("shape1没有引用Circle");
        }
    }
}
